import {createStore} from "vuex";

import {Position} from "../src/api";
import {Nav} from "../src/api";
import {Merchants} from "../src/api";



const store = createStore({
    state() {
        return{
            position:[],
            nav:null,
            merchants:null,
        }
    },
    getters: {},
    mutations: {
        getPosition(state, data) {
            state.position = data
        },
        getNav(state, data) {
            state.nav = data
        },
        getMerchants(state, data) {
            state.merchants = data
        },
    },
    actions: {
        getPosition(context) {
            Position(`/get-position`)
                .then(response => {
                    // console.log(response.data)
                    context.commit('getPosition', response.data)
                })
        },
        getNav(context) {
            Nav(`/get-nav`)
                .then(response => {
                    // console.log(response.data)
                    context.commit('getNav', response.data)
                })
        },
        getMerchants(context) {
            Merchants(`/get-merchants`)
                .then(response => {
                    console.log(response.data)
                    context.commit('getMerchants', response.data)
                })
        },
    }
})


export default store

























